﻿using Fonour.Application.Dtos;
using Fonour.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Fonour.MVC.Controllers
{
    [Authorize]
    public class HomeController : Controller
    {
        public IActionResult Index()
        {
            byte[] bUser;
            if (HttpContext.Session.TryGetValue("CurrentUser", out bUser))
            {
                var user = ByteConvertHelper.Bytes2Object<UserDto>(bUser);
                ViewBag.Name = user.Name;
                ViewBag.Email = user.EMail;
                ViewBag.CreateTime = user.CreateTime;
            }

            return View();
        }

        public IActionResult Error()
        {
            return View();
        }
    }
}
